﻿using Inovout.Cloud.Applications.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web;
using System.Web.Http.Routing;

namespace Inovout.Cloud.Web.Http
{
    public class HttpApplicationRoute : HttpRoute
    {
        public HttpApplicationInterface HttpApplicationInterface { get; set; }

        public HttpApplicationRoute(HttpApplicationInterface api)
            : base(api.TemplateUri)
        {
            this.HttpApplicationInterface = api;
        }

        public bool Match(string virtualPathRoot, HttpRequestMessage request)
        {
            int result = String.Compare(this.HttpApplicationInterface.HttpMethod.ToLower().ToString(), request.Method.ToString().ToLower(), true);
            return (result == 0 ? true : false) && GetRouteData(virtualPathRoot, request) != null;

        }

    }

}